<template>
	<view>
		<view class="banner">
			<image src="../static/images/WechatIMG1449.jpg" mode=""></image>
		</view>

		<!-- <view class="title">
			龙城街道三人篮球超级联赛
		</view> -->
		<view class="list" v-for="(item,ind) in list" :key="ind" @click="goDetail(item.id,item)">
			<image :src="imageUrl + item.contestLogo" mode=""></image>
			<view>{{item.contestName}}</view>
		</view>
		<uni-load-more style="background-color: #fff;" :status="loadingType"></uni-load-more>
	</view>

</template>

<script>
	import config from '@/config'
	import {
		getLeagueH5ContestList,
		getcontestBindingList
	} from '@/api/tournament/index.js'
	export default {
		data() {
			return {
				list: [],
				imageUrl: '',
				pageDate: {
					pageSize: 10,
					pageNum: 1
				},
				total: 0,
				loadingType: '',
				pageType: ''
			}
		},
		onShow() {
			this.imageUrl = config.imageUrl
			// let bindId = uni.getStorageSync('bindId')
			// if (bindId) {
			// 	// 绑定列表进来的查询
			// 	this.pageType = 'bind'
			// 	this.getBindList(bindId)
			// 	uni.setStorageSync('bindId', '')
			// } else {
			// 	this.pageType = 'init'
			// 	this.getList()
			// }
			this.pageType = 'init'
			this.getList()
		},
		async onReachBottom() {
			if (this.pageType == 'bind') return
			// 如果是绑定列表进来的 不需要分页 return掉后面操作
			if (this.list.length == this.total) {
				this.loadingType = 'no-more'
				return;
			}
			this.loadingType = 'loading'
			this.pageDate.pageNum += 1
			this.getList()
		},
		methods: {
			getBindList(id) {
				getcontestBindingList({
					id
				}).then(res => {
					this.list.push(...res.rows)
				})
			},
			//获取数据
			getList() {
				getLeagueH5ContestList(this.pageDate).then(res => {
					this.total = res.total
					this.list.push(...res.rows)
					if (this.list.length == this.total) {
						this.loadingType = 'no-more'
						return;
					}
				})
			},
			//联赛详情
			goDetail(id, item) {
				uni.setStorageSync('scoringWay', item.scoringWay)
				uni.navigateTo({
					url: '/pages/index?id=' + id + '&name=' + item.contestName + '&img=' + (item.contestLogo ? item
						.contestLogo : '')
				})
			}
		},
	}
</script>

<style scoped lang="scss">
	page {
		background-color: #efefef;
		height: 100%;
	}

	.banner {
		width: 100%;
		height: 372rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.title {
		width: 100%;
		margin: auto;
		padding: 40rpx;
		text-align: center;
		background-color: #fff;
		font-size: 32rpx;
		font-weight: 700;
	}

	.list {
		padding: 8rpx;
		width: 100%;
		background: #fff;
		text-align: center;

		image {
			width: 500rpx;
			height: 160rpx;
			border-radius: 10rpx;
			background-position: 50%;
			background-size: 100% 100%;
		}
	}
</style>